
package com.netease.xone.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.widget.LinearLayout;

import com.netease.pkgRelated.XoneConsts.BUNDLE_KEY;
import com.netease.pkgRelated.XoneConsts.SETTING_CONTAINER_TYPE;
import com.netease.xone.R;
import com.netease.xone.fragment.FragAbout;
import com.netease.xone.fragment.FragFeedBack;
import com.netease.xone.fragment.FragMoreApp;
import com.netease.xone.fragment.FragSetPicQuality;
import com.netease.xone.fragment.FragSetPush;
import com.netease.xone.fragment.FragSetReceiveMsg;
import com.netease.xone.fragment.FragmentBase;

public class ActivitySettingContainer extends ActivityX1Base {

    public static void launch(Context context, int type) {
        Intent i = new Intent(context, ActivitySettingContainer.class);
        i.putExtra(BUNDLE_KEY.SETTINGG_CHILD_TYPE, type);
        context.startActivity(i);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayout linear = new LinearLayout(this);
        linear.setId(R.id.activity_setting_container_id);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        linear.setLayoutParams(lp);
        setContentView(linear);
        Intent intent = getIntent();
        int type = 0;
        if (intent != null) {
            type = intent.getIntExtra(BUNDLE_KEY.SETTINGG_CHILD_TYPE, 0);
        }
        if (findViewById(R.id.activity_setting_container_id) != null && savedInstanceState == null) {
            FragmentManager fm = getSupportFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            FragmentBase frag = null;
            switch(type){
                case SETTING_CONTAINER_TYPE.set_pic_quality:
                    frag = new FragSetPicQuality();
                    break;
                case SETTING_CONTAINER_TYPE.set_message:
                    frag = new FragSetReceiveMsg();
                    break; 
                case SETTING_CONTAINER_TYPE.set_push:
                    frag = new FragSetPush();
                    break;  
                case SETTING_CONTAINER_TYPE.set_feedback:
                    frag = new FragFeedBack();
                    break; 
                case SETTING_CONTAINER_TYPE.set_about:
                    frag = new FragAbout(); 
                    break; 
                case SETTING_CONTAINER_TYPE.set_recommend:
                    frag = new FragMoreApp();
                    break; 
            }
           
            ft.add(R.id.activity_setting_container_id, frag);
            ft.commit();
        }
    }
}
